//
// Created by redcat1 on 12.05.2024.
//

#include "data_generator.h"
#include <random>

//
int GetRandomInt(int min, int max)
{
  return min + std::rand() / ((RAND_MAX + 1u) / (max + 1u - min));
}

//
double GetRandomDouble(double min, double max, int significantDigits)
{
  double value = 0.0;
  int degree = significantDigits;
  while (degree != 0)
  {
    value += GetRandomInt(0, 9) * pow(10, --degree);
  }

  const double scale = (max - min) / pow(10, significantDigits);
  return min + value * scale;
}

//
Rectangle GetRandomRectangle()
{
  const double width = GetRandomDouble(-1, 10, 3);
  const double length = GetRandomDouble(width, 10, 3);
  return Rectangle(width, length);
}

//
Circle GetRandomCircle()
{
  const double radius = GetRandomDouble(-1, 10, 3);
  return Circle(radius);
}

//
RightTriangle GetRandomRightTriangle()
{
  const double leg1 = GetRandomDouble(-1, 10, 3);
  const double leg2 = GetRandomDouble(leg1, 10, 3);
  return RightTriangle(leg1, leg2);
}
